package com.itheima.safe;

public class MyRunnable implements Runnable{
    private  int ticke=100;
   private Object obj=new Object();
    @Override
    public void run() {
        while (true){
            synchronized (obj) {
                if (ticke <= 0) {
                    break;
                } else {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    ticke--;
                    System.out.println(Thread.currentThread().getName() + "正在卖票,还剩" + ticke + "张");
                }
            }
        }

    }
}
